<?php

/**
 * 首页焦点图推荐管理
*
* @copyright zhanghuan
* @since 2012-03-23
*/

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/index/db_food_focus_pic_index.class.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();

function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;

}

function get_data()
{
	global $g_cgival, $g_pro, $g_show;

	$p = $g_cgival["p"];
	$pcount = $g_cgival["pcount"];
	$total_tj_num = 4;
	$current_tj_num = 0;

	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();

	// 实例化
	$db = new db_food_focus_pic_index();
	
	// 获取焦点图记录数据
	$data = $db->admin_get_list_by_site_id($site_id, $p, $pcount);
// 	print_r($data);
	if (is_array($data))
	{
		$g_show["data"] = $data;
		$current_tj_num = count($data);
	}
	else
	{
		$g_show["data_none"] = 1;
	}
	
	$g_show["total_tj_num"] = $total_tj_num;
	$g_show["current_tj_num"] = $current_tj_num;

}

try
{
	admin_check_login();

	check_cgi_pro();
	get_data();
	
	$g_show["error"] = 0;
	$g_show["errmsg"] = "";
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;

function show_pro()
{
	global $g_show;
	$smarty = p_get_smarty();
	$smarty->assign ($g_show);
	if($g_show["error"])
	{
		$smarty->display("error.html");
	}
	
	$smarty->display ( "foodv2/index/focus_pic_tuijian.html" );
}

?>